package com.smartleanx.module.hrm.service.esign.service.impl;


import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.smartleanx.module.hrm.dal.mysql.esign.HrmEContractTaskActorsMapper;
import com.smartleanx.module.hrm.service.esign.service.HrmEContractTaskActorsService;
import com.smartleanx.module.hrm.service.esign.temp.po.HrmEContractTaskActors;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * e签宝合同参与者Service实现
 *
 * @author xzq
 * @since 2025-07-07 16:43:08
 */
@Service
public class HrmEContractTaskActorsServiceImpl extends ServiceImpl<HrmEContractTaskActorsMapper, HrmEContractTaskActors> implements HrmEContractTaskActorsService {


    @Override
    public List<HrmEContractTaskActors> getTaskActorListByTaskId(Long taskId) {
        LambdaQueryWrapper<HrmEContractTaskActors> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(HrmEContractTaskActors::getDataStatus,1);
        queryWrapper.eq(HrmEContractTaskActors::getTaskId,taskId);
        return list(queryWrapper);
    }

    @Override
    public HrmEContractTaskActors getTaskActorListByTaskIdAndActorType(Long taskId, String actorType) {
        LambdaQueryWrapper<HrmEContractTaskActors> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(HrmEContractTaskActors::getDataStatus,1);
        queryWrapper.eq(HrmEContractTaskActors::getTaskId,taskId);
        queryWrapper.eq(HrmEContractTaskActors::getActorType,actorType);
        return getOne(queryWrapper);
    }

    @Override
    public List<HrmEContractTaskActors> getTaskActorListByActorName(String actorName) {
        return list(new LambdaQueryWrapper<HrmEContractTaskActors>()
        .eq(HrmEContractTaskActors::getDataStatus,1)
        .eq(HrmEContractTaskActors::getActorName,actorName));
    }

    @Override
    public List<HrmEContractTaskActors> getTaskActorListByTaskId(List<Long> taskIds) {
        if(CollUtil.isEmpty(taskIds)){
            return new ArrayList<>();
        }
        LambdaQueryWrapper<HrmEContractTaskActors> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(HrmEContractTaskActors::getDataStatus,1);
        queryWrapper.in(HrmEContractTaskActors::getTaskId,taskIds);
        return list(queryWrapper);
    }
}
